package org.siam.impl.data.formatting {
	
	import flash.utils.Dictionary;
	
	import mx.formatters.Formatter;
	
	import org.siam.core.data.formatting.IFormatterRegistry;
	import org.siam.impl.data.formatting.DefaultFormatter;

	public class FormatterRegistry implements IFormatterRegistry {
		
		private var _registry:Dictionary = new Dictionary();
		
		public function FormatterRegistry() {
		}
		
		public function register(id:String, formatter:Formatter):void {
			_registry[id] = formatter;			
		}
		
		public function has(id:String):Boolean {
			return _registry.hasOwnProperty(id);
		}
		
		public function find(id:String):Formatter {
			return has(id) ? _registry[id] : DefaultFormatter.INSTANCE;
		}
	}
}